package cn.cas.mango.util.keywordsBatch;
import cn.cas.mango.util.dbscan.Data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class KeywordsCast {
  List<Data> dataList = new ArrayList<>();
  public KeywordsCast(List<Data> dataList) {
    this.dataList.addAll(dataList);
  }
  public Map<String, List<String>> getClusterData() {
    Map<String, List<String>> ret = new HashMap<>();
    for (Data data : dataList) {
      Set<String> keywords = data.getKeywords();
      for (String keyword : keywords) {
        if (!ret.containsKey(keyword)) {
          ret.put(keyword, new ArrayList<>());
        }
        ret.get(keyword).add(data.getId());
      }
    }
    return ret;
  }
}
